package com.zhuojy.equity.mall.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.AddressBook;
import com.zhuojy.equity.mall.admin.common.entity.AddressBook2;
import com.zhuojy.equity.mall.admin.dal.mapper.AddressBookMapper2;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
@Slf4j
@RequiredArgsConstructor
public class AddressBookService2 extends ServiceImpl<AddressBookMapper2 ,AddressBook2> {
    public IPage queryAddress2(AddressBook2 addressBook2) {
        IPage page = new Page<>(addressBook2.getCurrentPage(),addressBook2.getPageSize());
        LambdaQueryWrapper<AddressBook2> lambdaQueryWrapper = Wrappers.lambdaQuery();

        if (StringUtils.hasText(addressBook2.getName())){
            lambdaQueryWrapper.like(AddressBook2::getName,addressBook2.getName());
        }
        if (addressBook2.getFromColumn()!=null){
            lambdaQueryWrapper.like(AddressBook2::getFromColumn,addressBook2.getFromColumn());
        }
        page =page(page, lambdaQueryWrapper);

        return page;
    }
}
